package com.example.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.example.entity.Advertisement;
import com.example.service.AdvertisementService;

import io.swagger.annotations.ApiOperation;

/**
 * Created by douyx on 2018/03/26.
 */
@RestController
@RequestMapping("api/advertise")
public class AdvertisementController {

	@Autowired
	AdvertisementService advertisementService;

	@ApiOperation(value = "查询信息", notes = "查询信息")
	@RequestMapping(value = "/query", method = RequestMethod.POST)
	Map<String, Object> query(@RequestBody  Map map) {
		return advertisementService.query(map);
	}

	@ApiOperation(value = "查询所有信息", notes = "查询信息")
	@RequestMapping(value = "/queryAll", method = RequestMethod.POST)
	Map<String, Object> queryAll() {
		return advertisementService.queryAll();
	}

	@ApiOperation(value = "新增信息", notes = "新增信息")
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	Map<String, Object> add(@RequestBody Advertisement advertisement) {
		return advertisementService.add(advertisement);
	}

	@ApiOperation(value = "删除信息", notes = "删除信息")
	@RequestMapping(value = "/delete", method = RequestMethod.POST)
	Map<String, Object> delete(@RequestBody  Map map) {
		List<String> ids = (List<String>)map.get("ids");
		return advertisementService.delete(ids);
	}

	//修改广告信息
	@ApiOperation(value = "修改广告信息", notes = "修改广告")
	@RequestMapping(value = "/upDate", method = RequestMethod.POST)
	Map<String, Object> upDate(@RequestBody Advertisement advertisement) {
		return advertisementService.upDate(advertisement);
	}

	//根据id 查询
	@ApiOperation(value = "根据id查询", notes = "查询广告")
	@RequestMapping(value = "/queryById",method = RequestMethod.POST)
	Map<String, Object> queryById(@RequestBody Advertisement advertisement) {
		return advertisementService.queryById(advertisement);
	}

}
